package com.third.func.web

import android.content.Intent
import android.os.Bundle
import android.widget.ArrayAdapter
import android.widget.ListView
import androidx.appcompat.app.AppCompatActivity

class TestWebActivity : AppCompatActivity() {

    companion object {
        val webUrlMap = mutableMapOf<String, String>().apply {
            // NEW
            put("今日热点", "http://web.sygjx.com/tool/jrrb/?bb=106")
            put("脱单盲盒", "http://tdmh.sygjx.com")
            put("匿名信", "https://sms.sygjx.com")
            put("匿名墙", "http://nmq.sygjx.com")
            // 生活常用
            put("  ", "")
            put(">>> 生活常用 <<<", "")
            put("IP地址查询", "https://tool.liumingye.cn/ip/")
            put("垃圾分类查询", "https://tool.liumingye.cn/ljcx/")
            put("女装国际尺码对照表", "https://www.dute.org/womens-clothing-size")
            put("男装国际尺码对照表", "https://www.dute.org/mens-clothing-size")
            put("世界各国首都", "https://www.dute.org/capital")
            put("全国车牌号简称", "https://www.dute.org/chepai")
            put("银行卡信息查询", "https://www.dute.org/bank-card-info")
            put("骚扰电话查询", "https://www.dute.org/sao-rao-dian-hua")
            put("Whois查询", "https://tools.miku.ac/whois_query")
            put("汉语词典", "https://www.zdic.net/?uc_biz_str=OPT%3ABACK_BTN_STYLE%400%7COPT%3ATOOLBAR_STYLE%401")
            put("汉典", "https://www.zdic.net/?uc_biz_str=OPT%3ABACK_BTN_STYLE%400%7COPT%3ATOOLBAR_STYLE%401")
            put("格式转换神器", "https://www.alltoall.net/")
            put("全网音乐搜索", "http://tool.liumingye.cn/music/?page\\u003dsearchPage")
            put("GIF搜索", "https://www.soogif.com/phone/index")
            put("在线年龄计算器", "https://www.dute.org/age-calculator")
            put("拼音字母表", "https://www.dute.org/zimu")
            // 文本相关
            put("   ", "")
            put(">>> 文本相关 <<<", "")
            put("加密文本", "https://paste.liumingye.cn")
            put("中文转拼音", "https://tool.liumingye.cn/pinyin/")
            put("随机密码生成器", "https://tool.liumingye.cn/password/")
            put("文本差异比较", "http://tool.mkblog.cn/contrast/")
            put("简体字繁体字互转", "https://tools.miku.ac/c2c")
            put("汉字转拼音", "https://tools.miku.ac/pinyin")
            put("彩色文字生成", "https://www.dute.org/colorful-text")
            put("怪异英文字生成", "https://www.dute.org/weird-fonts")
            put("中英混排工具", "https://www.dute.org/type-setting")
            put("文章字数统计", "https://www.dute.org/word-count")
            put("文本去重工具", "https://www.dute.org/text-remove-duplicates")
            put("文本添加行号", "https://www.dute.org/text-ordered-list")
            put("在线文本比较", "https://www.dute.org/diff")
            put("文本空行清除", "https://www.dute.org/text-blank-line-remove")
            put("彩虹屁生成器", "https://chp.shadiao.app/")
            put("数字添加千分位", "https://www.dute.org/number-with-comma")
            put("艺术字体制作", "https://www.qt86.com/")
            put("营销文案制作", "https://maorx.cn/yxh/")
            put("对联生成器", "https://ai.binwang.me/couplet/")
            put("押韵助手", "https://yayun.la/m/")
            // 单位转换
            put("    ", "")
            put(">>> 单位转换 <<<", "")
            put("温度单位转换", "https://tools.miku.ac/temperature_conversion")
            put("压力单位转换", "https://tools.miku.ac/convert_pressure")
            put("重量单位换算", "https://tools.miku.ac/convert_weight")
            put("体积单位转换", "https://tools.miku.ac/convert_volume")
            put("速度单位转换", "https://tools.miku.ac/convert_speed")
            put("力单位转换", "https://tools.miku.ac/convert_force")
            put("密度单位转换", "https://tools.miku.ac/convert_density")
            put("时间单位转换", "https://tools.miku.ac/convert_time")
            put("储存数据单位转换", "https://tools.miku.ac/convert_storage")
            put("实时汇率转换", "https://tools.miku.ac/exchange_rate")
            put("功率单位转换", "https://tools.miku.ac/convert_power")
            put("长度单位转换", "https://tools.miku.ac/convert_length")
            put("面积单位转换", "https://tools.miku.ac/convert_area")
            // 开发相关
            put("     ", "")
            put(">>> 开发相关 <<<", "")
            put("全能进制转换", "https://tools.miku.ac/hexconvert")
            put("支持字符串md5、sha等计算", "https://www.wanandroid.com/tools/digit")
            put("DES加解密", "https://www.dute.org/des")
            put("AES加解密", "https://www.dute.org/aes")
            put("SHA哈希加密", "https://www.dute.org/sha")
            put("正则大全", "https://tools.miku.ac/any_rule")
            put("常用Linux命令", "https://www.dute.org/linux-command")
            put("HTML转JSX", "https://www.ygktool.cn/app/html2jsx")
            put("HTML代码压缩工具", "https://www.dute.org/html-minify")
            put("HTML代码格式化", "https://www.dute.org/html-formatter")
            put("JS代码压缩工具", "https://www.dute.org/js-compress")
            put("JS代码格式化", "https://www.dute.org/js-formatter")
            put("JSON格式化效验工具", "https://www.dute.org/json")
            put("CSS代码压缩工具", "https://www.dute.org/css-minify")
            put("CSS代码格式化", "https://www.dute.org/css-formatter")
            put("CSS气泡生成器", "https://www.dute.org/css-arrow")
            put("XML转JSON", "https://tools.miku.ac/xml2json")
            put("XML代码压缩工具", "https://www.dute.org/xml-minify")
            put("XML代码格式化", "https://www.dute.org/xml-formatter")
        }

        val webAssetUrlMap = mutableMapOf<String, String>().apply {
            put("到数日", "file:///android_asset/tools/daoshuri/index.html")
            put("二十四节气", "file:///android_asset/tools/ershisijieqi/index.html")
            put("法定节假日", "file:///android_asset/tools/fadingjiejiari/index.html")
            put("符号大全", "file:///android_asset/tools/fuhaodaquan/index.html")
            put("鬼畜字符生成器", "file:///android_asset/tools/guichuzifushengcheng/index.html")
            put("函数图像绘制工具", "file:///android_asset/tools/hanshuhuitu/index.html")
            put("交通标志", "file:///android_asset/tools/jiaotongbiaozhi/index.html")
            put("结婚纪念日", "file:///android_asset/tools/jiehunjinianri/index.html")
            put("* 今年的时间进度", "file:///android_asset/tools/jinniandeshijianjindu/index.html")
            put("今天吃什么", "file:///android_asset/tools/jintianchishenme/index.html")
            put("进制转换", "file:///android_asset/tools/jinzhizhuanhuan/index.html")
            put("历史朝代", "file:///android_asset/tools/lishichaodai/index.html")
            put("流体模拟器", "file:///android_asset/tools/liutimoniqi/index.html")
            put("LOGO生成", "file:///android_asset/tools/logoshengcheng/index.html")
            put("汽车标志大全", "file:///android_asset/tools/qichebiaozhidaquan/index.html")
            put("亲戚称呼计算", "file:///android_asset/tools/qinqichenghujisuan/index.html")
            put("世界各国首都", "file:///android_asset/tools/shijiegeguoshoudu/index.html")
            put("时钟1", "file:///android_asset/tools/shizhongdaquan/bs.html")
            put("时钟2", "file:///android_asset/tools/shizhongdaquan/hs.html")
            put("时钟3", "file:///android_asset/tools/shizhongdaquan/jd.html")
            put("随机密码生成器", "file:///android_asset/tools/suijimimashengchengqi/index.html")
            put("文本差异比较", "file:///android_asset/tools/wenbenchayibijiao/index.html")
            put("元素周期表", "file:///android_asset/tools/yuansuzhouqibiao/index.html")
            put("字数统计", "file:///android_asset/tools/zishutongji/index.html")
            //------------------------------
            put("电吉他", "file:///android_asset/games/dianjita/index.html")
            put("电子木鱼", "file:///android_asset/games/dianzimuyu/index.html")
            put("逗猫", "file:///android_asset/games/doumao/index.html")
            put("黑洞模拟器", "file:///android_asset/games/heidongmoniqi/index.html")
            put("色彩敏感度测试", "file:///android_asset/games/secaiminganduceshi/index.html")
            put("视力检测", "file:///android_asset/games/shilijiance/index.html")
            put("烟花模拟器", "file:///android_asset/games/yanhuamoniqi/index.html")
            put("见缝插针", "file:///android_asset/games/jianfengchazhen/index.html")
            put("架子鼓", "file:///android_asset/games/jiazigu/index.html")
            //------------------------------
            put("* 2048", "file:///android_asset/games/2048/index.html")
            put("* 保护堆芯", "file:///android_asset/games/baohuduixin/index.html")
            put("* 躲避小球", "file:///android_asset/games/duobixiaoqiu/index.html")
            put("* 飞机躲避障碍", "file:///android_asset/games/feijiduobizhangai/index.html")
            put("* 盖塔楼", "file:///android_asset/games/gaitalou/index.html")
            put("* 过桥", "file:///android_asset/games/guoqiao/index.html")
            put("* 黑白棋", "file:///android_asset/games/heibaiqi/index.html")
            put("* 恐龙快跑", "file:///android_asset/games/konglongkuaipao/index.html")
            put("* 魔方", "file:///android_asset/games/mofang/index.html")
            put("* 切积木", "file:///android_asset/games/qiejimu/index.html")
            put("* 石头剪刀布", "file:///android_asset/games/shitoujiandaobu/index.html")
            put("* 数字华容道", "file:///android_asset/games/shuzihuarongdao/index.html")
            put("* 贪吃蛇", "file:///android_asset/games/tanchishe/index.html")
            put("* 像素鸟", "file:///android_asset/games/xiangsuniao/index.html")
            put("* 旋转六边形", "file:///android_asset/games/xuanzhuanliubianxing/index.html")
            put("* 一个都不能死", "file:///android_asset/games/yigedoubunengsi/index.html")
            put("* 纸牌记忆游戏", "file:///android_asset/games/zhipaijiyiyouxi/index.html")
            put("* 掷骰子", "file:///android_asset/games/zhitouzi/index.html")
            put("* 最强眼力", "file:///android_asset/games/zuiqiangyanli/index.html")

        }
    }

    private val showTitleMap = mutableMapOf<String, String>().apply {
        put("到数日", "file:///android_asset/tools/daoshuri/index.html")
        put("二十四节气", "file:///android_asset/tools/ershisijieqi/index.html")
        put("法定节假日", "file:///android_asset/tools/fadingjiejiari/index.html")
        put("符号大全", "file:///android_asset/tools/fuhaodaquan/index.html")
        put("* 今年的时间进度", "file:///android_asset/tools/jinniandeshijianjindu/index.html")
        put("流体模拟器", "file:///android_asset/tools/liutimoniqi/index.html")
        put("元素周期表", "file:///android_asset/tools/yuansuzhouqibiao/index.html")
        put("电子木鱼", "file:///android_asset/games/dianzimuyu/index.html")
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_test_web)

        val data_1 = webUrlMap.keys.toTypedArray()
        val adapter_1 = ArrayAdapter(this, android.R.layout.simple_list_item_1, data_1)
        val list_view_1 = findViewById<ListView>(R.id.list_view_1)
        list_view_1.adapter = adapter_1
        list_view_1.setOnItemClickListener { adapterView, view, i, l ->
            val clickUrl = webUrlMap.get(data_1.get(i))
            if (clickUrl != null && clickUrl.length > 0) {
                val intent = Intent()
                intent.putExtra("网址", clickUrl)
                intent.setClass(this, WebBrowserActivity::class.java)
                startActivity(intent)
            }

        }

        val data_2 = webAssetUrlMap.keys.toTypedArray()
        val adapter_2 = ArrayAdapter(this, android.R.layout.simple_list_item_1, data_2)
        val list_view_2 = findViewById<ListView>(R.id.list_view_2)
        list_view_2.adapter = adapter_2
        list_view_2.setOnItemClickListener { adapterView, view, i, l ->
            val clickUrl = webAssetUrlMap.get(data_2.get(i))
            if (clickUrl != null && clickUrl.length > 0) {
                val intent = Intent()
                intent.putExtra("网址", clickUrl)
                intent.setClass(this, WebBrowserActivity::class.java)
                if (showTitleMap.values.contains(clickUrl)) {
                    intent.putExtra("isShowTitleBar", 1)
                    intent.putExtra("title", data_2.get(i))
                }
                startActivity(intent)
            }
        }
    }


}

